$(function(){
	var page = 1;
	var headImage = localStorage.getItem("head_image");
	var myName = localStorage.getItem("my_name");
	var btn = $("#bottom_more");
	$("#message_w").click(function(){
		location.href = "send_private_massage.html";
	});
	$("#imagehead2").attr("src", headImage);
	$("#myName").text(myName);
	var $modal = $('#my-modal-loading');
	var query_id = localStorage.getItem("query_id");
	var uid = localStorage.getItem("person_id");
	var lookOverOtherCreatePublish = "http://yx.fxtourong.com/V1/Member/lookOverOtherCreatePublish" + "?store_id=" + query_id;
	getData();
	btn.click(function(){
		page = page + 1;
		getData();
	});
	function getData(){
		$modal.modal();
		$.ajax({
			type: "POST",
			url: lookOverOtherCreatePublish,
			data: {
				uid : uid,
				page: page
			},
			dataType: "json",
			success: function(data) {
				$modal.modal('close');
				var code = data.code;
				console.log("code:" + data.code);
				if(code == "1") {
					var jsonStr = data.data;
					if(page == 1){
						if(jsonStr.length == 10){
							btn.css("visibility", "visible");
						}
					}
					for(var i = 0; i<jsonStr.length; i++){
						var industry = jsonStr[i];
						var typeStr = "语音";
						if(industry.g_type == "1"){
							typeStr = "语音";
						} else if(industry.g_type == "3") {
							typeStr = "文本";
						} else {
							typeStr = "图文";
						}
						var countimage = 0;
						if(typeStr == "图文"){
							countimage = industry.cover.length;
							for(var j = 0; j < countimage; j++){
								if(j == 0){
									image1 = industry.cover[j];
								} else if(j == 1){
									image2 = industry.cover[j];
								} else {
									image3 = industry.cover[j];
								}
							}
						} 
						if(typeStr == "语音"){
							var details = industry.details;
							if(details == "" || details == undefined || details == null){
								details = "语音";
							}
							$("#query_ul").append("<li value='" + (((page-1) * 10) + i) + "' class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left detail_item' onclick=''>" + 
					        "<div class='am-list-main' style='margin-left:20px;margin-right:20px;'>" + 
					            "<div class='am-list-item-hd'>" + 
					            	"<img src='../../../public/yx/img/yuyin1.svg' class='am-radius' style='height: 28px;display: inline;float: right; margin-right:10px;'/>" +
					            "</div>" +
					            "<div class='am-list-item-text' style='margin-top: 8px;'><span style='font-size: 16px;color: #BBB;'>" + details + "</span></div>" + 
								"<div class='am-list-item-text' style='margin-top: 8px;'>" + 
									"<span style='font-size: 16px;color: #BBBBBB;'>" + industry.created_time  + "</span>" + 
								"</div>" + 
									
								"</div>" + 
					        "</div>" + 
				      	"</li>");
						} else if(typeStr == "文本") {
							$("#query_ul").append("<li value='" + (((page-1) * 10) + i) + "' class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left detail_item' onclick=''>" + 
					        "<div class='am-list-main' style='margin-left:20px;margin-right:20px;'>" + 
					            "<div class='am-list-item-text' style='margin-top: 8px;'><span style='font-size: 16px;color: #BBB;'>" + industry.details + "</span></div>" + 
								"<div class='am-list-item-text' style='margin-top: 8px;'>" + 
									"<span style='font-size: 16px;color: #BBBBBB;'>" + industry.created_time  + "</span>" + 
								"</div>" + 
					        "</div>" + 
				      	"</li>");
						} else {
							if(countimage == 1){
								$("#query_ul").append("<li value='" + (((page-1) * 10) + i) + "' class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left detail_item' onclick=''>" + 
					        
					        "<div class='am-u-sm-10 am-list-main' style='margin-left:20px;margin-right:20px;'>" + 
					            "<div class='am-list-item-text' style='margin-top: 8px;'><span style='font-size: 16px;color: #BBB;'>" + industry.details + "</span></div>" + 
								"<div class='am-list-item-text' style='margin-top: 8px;'>" + 
									"<span style='font-size: 16px;color: #BBBBBB;'>" + industry.created_time  + "</span>" + 
									"<span style='font-size: 16px;color: #BBBBBB;float: right;margin-right: 10px;visibility: hidden;'>" + industry.created_time + "</span>" +
								"</div>" + 
								"<div style='margin-top: -12px;'>" + 
									"<img src='" + image1 + "' class='am-radius' style='width:68px;height: 68px;display: inline;margin-top: 14px;'/>" + 
								"</div>" + 
					        "</div>" + 
				      	"</li>");
							} else if (countimage == 2){
								$("#query_ul").append("<li value='" + (((page-1) * 10) + i) + "' class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left detail_item' onclick=''>" + 
					        
					        "<div class='am-u-sm-10 am-list-main' style='margin-left:20px;margin-right:20px;'>" + 
					            "<div class='am-list-item-text' style='margin-top: 8px;'><span style='font-size: 16px;color: #BBB;'>" + industry.details + "</span></div>" + 
								"<div class='am-list-item-text' style='margin-top: 8px;'>" + 
									"<span style='font-size: 16px;color: #BBBBBB;'>" + industry.created_time  + "</span>" + 
									"<span style='font-size: 16px;color: #BBBBBB;float: right;margin-right: 10px;visibility: hidden;'>" + industry.created_time + "</span>" +
								"</div>" + 
								"<div style='margin-top: -12px;'>" + 
									"<img src='" + image1 + "' class='am-radius' style='width:68px;height: 68px;display: inline;margin-top: 14px;'/>" + 
									"<img src='" + image2 + "' class='am-radius' style='width:68px;height: 68px;display: inline;margin-top: 14px;margin-left: 6px;'/>" + 
								"</div>" + 
					        "</div>" + 
				      	"</li>");
							} else {
								$("#query_ul").append("<li value='" + (((page-1) * 10) + i) + "' class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left detail_item' onclick=''>" + 
					        "<div class='am-u-sm-10 am-list-main' style='margin-left:20px;margin-right:20px;'>" + 
					            "<div class='am-list-item-text' style='margin-top: 8px;'><span style='font-size: 16px;color: #BBB;'>" + industry.details + "</span></div>" + 
								"<div class='am-list-item-text' style='margin-top: 8px;'>" + 
									"<span style='font-size: 16px;color: #BBBBBB;'>" + industry.created_time  + "</span>" + 
									"<span style='font-size: 16px;color: #BBBBBB;float: right;margin-right: 10px;visibility: hidden;'>" + industry.created_time + "</span>" +
								"</div>" + 
								"<div style='margin-top: -12px;'>" + 
									"<img src='" + image1 + "' class='am-radius' style='width:68px;height: 68px;display: inline;margin-top: 14px;'/>" + 
									"<img src='" + image2 + "' class='am-radius' style='width:68px;height: 68px;display: inline;margin-top: 14px;margin-left: 6px;'/>" + 
									"<img src='" + image3 + "' class='am-radius' style='width:68px;height: 68px;display: inline;margin-top: 14px;margin-left: 6px;'/>" + 
								"</div>" + 
					        "</div>" + 
				      	"</li>");
							}
							
						}
						
					}
				} else {
					$modal.modal('close');
					btn.css("visibility", "hidden");
				}
			},
			error: function(e){
				$modal.modal('close');
				alert("服务请求异常！");
			}
		});
	}
	
	
});
